package creator;

public class Main {
    public static void main(String[] args) {
        if (args.length == 1 && args[0].equals("-h")) {
            System.out.println("用法: java YourProgramName -k key -i IssuedTime -e ExpiryTime");
            System.out.println("参数说明:");
            System.out.println("-k: 许可证密钥");
            System.out.println("-i: 许可证生效时间（格式: yyyy-MM-dd HH:mm:ss）");
            System.out.println("-e: 许可证过期时间（格式: yyyy-MM-dd HH:mm:ss）");
            System.out.println("示例: java YourProgramName -k ABC123 -i \"2024-05-09 12:00:00\" -e \"2024-05-10 12:00:00\"");
        } else {
            // 处理其他参数
            String key = "";
            String IssuedTime = "";
            String ExpiryTime = "";

            // 判断传入参数
            for (int i = 0; i < args.length; i++) {
                if (args[i].equals("-k") && i + 1 < args.length) {
                    key = args[i + 1];
                } else if (args[i].equals("-i") && i + 1 < args.length) {
                    IssuedTime = args[i + 1];
                } else if (args[i].equals("-e") && i + 1 < args.length) {
                    ExpiryTime = args[i + 1];
                }
            }

            if (key.isEmpty() || IssuedTime.isEmpty() || ExpiryTime.isEmpty()) {
                System.out.println("参数不完整。请使用 '-h' 获取帮助信息。");
            } else {
                Create create = new Create();
                try {
                    create.Create(key, IssuedTime, ExpiryTime);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
